#ifndef FIELDVISITORS_H
#define FIELDVISITORS_H

#include "src/core/scene/abstractfieldvisitor.h"
#include "src/core/scene/colormap.h"
#include "src/gui/itemwidget.h"

#include <QDebug>

class SphericalFieldVisitor : public FieldVisitor
{
public:
  SphericalFieldVisitor(ItemWidget* se, const ColorMap& colors, const double size_factor = 1.0, const double d_r = 0.01)
    : s_factor(size_factor), scene(se), map(colors), def_radius(d_r) {}
  void drawPoint(const Vector3& pos, const Field::float_type value, bool selected = false )
  {
    scene->drawSphere(pos, def_radius*s_factor, map[value], 1);
  }
  virtual void drawField(const Field& field)
  {
    double min = 0, max = 0;
    for(Field::int_type i = 0, e = field.count(); i != e; ++i)
    {
      FieldNode f = field[i];
      min = (f.value < min) ? f.value : min;
      max = (f.value > max) ? f.value : max;
      drawPoint(f.point, f.value);
    }
  }

private:
  double s_factor;
  ItemWidget* scene;
  ColorMap map;
  const double def_radius;
};

#endif // FIELDVISITORS_H
